#include <STC89C5xRC.H>
#include "Timer0.H"
#include "Key.H"
#include <INTRINS.H>
#include "Delay.H"

unsigned char KeyNumber,LEDMode;

void main()
{
	P2=0xFE;
	Timer0_Init();
	while(1)
	{	
		KeyNumber=Key();
		if(KeyNumber)
		{
			if(KeyNumber==1)
			{
				LEDMode++;
				if(LEDMode>=2)LEDMode=0;
			}
		}
	}
}


void Timer0_Routine() interrupt 1//定时器0对应的interrupt 1，为其对应的中断函数
{	
  unsigned int T0Count;
	TL0 = 0x00;		//设置定时初值
	TH0 = 0x4C;		//设置定时初值
	T0Count++;
	if(T0Count==10)
	{	
				T0Count=0;
		if(LEDMode==0)
			P2=_crol_(P2,1);
		if(LEDMode==1)
			P2=_cror_(P2,1);
	}
}